package org.tpc.printtolls.model;

import java.time.LocalDateTime;

/**
 * 打印结果封装类
 */
public class PrintResult {
    
    /**
     * 是否成功
     */
    private boolean success;
    
    /**
     * 错误信息
     */
    private String errorMessage;
    
    /**
     * 打印任务ID
     */
    private String jobId;
    
    /**
     * 打印开始时间
     */
    private LocalDateTime startTime;
    
    /**
     * 打印完成时间
     */
    private LocalDateTime endTime;
    
    /**
     * 打印页数
     */
    private int pageCount;
    
    /**
     * 实际打印份数
     */
    private int actualCopies;

    public PrintResult() {}
    
    public PrintResult(boolean success, String errorMessage) {
        this.success = success;
        this.errorMessage = errorMessage;
        this.startTime = LocalDateTime.now();
    }
    
    public static PrintResult success(String jobId, int pageCount, int actualCopies) {
        PrintResult result = new PrintResult(true, null);
        result.setJobId(jobId);
        result.setPageCount(pageCount);
        result.setActualCopies(actualCopies);
        result.setEndTime(LocalDateTime.now());
        return result;
    }
    
    public static PrintResult failure(String errorMessage) {
        return new PrintResult(false, errorMessage);
    }

    // Getters and Setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getJobId() {
        return jobId;
    }

    public void setJobId(String jobId) {
        this.jobId = jobId;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getActualCopies() {
        return actualCopies;
    }

    public void setActualCopies(int actualCopies) {
        this.actualCopies = actualCopies;
    }

    @Override
    public String toString() {
        return "PrintResult{" +
                "success=" + success +
                ", errorMessage='" + errorMessage + '\'' +
                ", jobId='" + jobId + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", pageCount=" + pageCount +
                ", actualCopies=" + actualCopies +
                '}';
    }
} 